import sys
from os.path import dirname, abspath
import os
from flask import Flask
# 将 routes 目录添加到系统路径
routes_dir = abspath(dirname(__file__) + '/routes')
sys.path.insert(0, routes_dir)

from routes.auth_routes import auth_bp
from routes.user_routes import user_bp
from routes.order_routes import order_bp
from routes.merchant_routes import merchant_bp
from routes.admin_routes import admin_bp

# 数据库配置
mysql_pwd = os.getenv('MYSQL_PWD', "123456")  # 默认值为 "123456"
db_name = os.getenv('DB_NAME', "appDB")      # 默认值为 "appDB"

# 初始化 Flask 应用
app = Flask(__name__)

# 注册所有蓝图
app.register_blueprint(auth_bp, url_prefix='/auth')       # 用户认证相关路由
app.register_blueprint(user_bp, url_prefix='/user')       # 用户功能相关路由
app.register_blueprint(order_bp, url_prefix='/order')     # 订单功能相关路由
app.register_blueprint(merchant_bp, url_prefix='/merchant')  # 商家功能相关路由
app.register_blueprint(admin_bp, url_prefix='/admin')     # 管理员功能相关路由

if __name__ == '__main__':
    app.run(debug=True)